﻿#include"UnorderedSet.h"
#include"Hash.h"
#include"UnorderedMap.h"
void test1()
{
	Unordered_Set<int> s;
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14, 3,3,15 };
	for (auto e : a)
	{
		s.insert(e);
	}
	Unordered_Set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		// 不⽀持修改
		//*it += 1;
		cout << *it << " ";
		++it;
	}
	cout << endl;
	cout << s.find(100)._node << endl;
	cout << s.find(15)._node << endl;
	cout << s.erase(15) << endl;
	cout << s.insert(100).second << endl;
	cout << s.insert(3).second << endl;
	cout << s.insert(16).second << endl;
	cout << s.find(15)._node << endl;

}
void test2()
{
	
		Unordered_Map<string, string> dict;
		dict.insert({ "sort", "排序" });
		dict.insert({ "left", "左边" });
		dict.insert({ "right", "右边" });
		dict["left"] = "左边，剩余";
		dict["insert"] = "插入";
		dict["string"];
		Unordered_Map<string, string>::iterator it = dict.begin();
		while (it != dict.end())
		{
			// 不能修改first，可以修改second
			//it->first += 'x';
			cout << it->first << ":" << it->second << endl;
			++it;
		}
		cout << dict.insert({ "sort","排序" }).second << endl;
		cout << dict.find("sort")._node << endl;
		
		cout << endl;
		dict.erase("sort");
		it = dict.begin();
		while (it != dict.end())
		{
			cout << it->first << ":" << it->second << endl;
			++it;
		}
		cout << dict.insert({ "sort","排序" }).second << endl;

		cout << dict.find("sort")._node << endl;
		cout << endl;
	
}

int main()
{
	test1();
	return 0;
}